<?php
/**
 * Created by PhpStorm.
 * User: hgq
 * Date: 16/6/24
 * Time: 下午1:23
 */
use yii\helpers\Url;
$web = Url::base();

?>

<script type="text/javascript" src="<?= $web ?>/js/jquery.tooltips.js"></script>
<script>
    $(function($){
        tooltipsPreview();
    });
    //筛选
    function filter() {

        var href = window.location.href;
        href = setUrlParam(href, 'tag_Id', $('#head_tag_id').val());

        window.location.href = href;
    }
    //同步分类(同步上级机构分类)
    function synNcGoodsTag() {

        var data = {};

        loading.show();
        requestJson("syn-goods-tag-handle", data, true, function (response) {
            loading.hide();
            if (response.status == 0) {
                filter();
                $("#hint_message").text('操作成功！');
            } else {
                $("#hint_message").text('操作失败！' + response.message);
            }
            $("#hintMessageModal").modal('show');
        });

    }
</script>

<div class="panel panel-default">
<div class="panel-body">
    <div class="form-inline">
        <div class="btn-group">
            <button class="btn btn-primary" type="button" onclick="synNcGoodsTag()"><i class="fa fa-refresh"></i>
                同步NC商品扩展分类
            </button>

        </div>
        <div class="pull-right">
            <div class="form-group">
                <label class="sr-only" for="exampleInputPassword2">机构</label>
                <select class="form-control popovers" style="width: 160px;" id="head_tag_id">
                    <option value="">---选择分类---</option>
                    <?php
                        foreach($tagList as $item){
                    ?>
                            <option value="<?=$item['id']?>" <?=$item['id'] == $tag_Id ? 'selected="selected"' : '' ?>><?=$item['name']?></option>
                    <?php
                        }
                    ?>
                </select>
            </div>
            <button type="button" class="btn btn-primary" onclick="filter()"><i class="fa fa-search"></i> 搜索
            </button>
        </div>
    </div>
</div>

<!-- body table-->
<div class="panel panel-default" id="goodsList">
    <div class="panel-body">
        <div class="table-responsive">
            <table class="table table-bordered table-hover table-condensed">
                <thead class="nowrap">
                <tr>
                    <th style="width:20%">产品图片</th>
                    <th style="width:20%">分类名称</th>
                    <th style="width:20%">分类代码</th>
                    <th style="width:20%">产品代码</th>
                    <th style="width:20%">产品名称</th>

                </tr>
                </thead>
                <tbody>
                    <?php
                        foreach($list as $item){
                ?>
                    <tr>
                        <td  align="center" style="vertical-align:middle;">
                            <a href="javascript:void(0)" class="tooltips" rel="<?= $item['image_url'] ?>" target="_blank" >
                                <img src="<?= $item['image_url'] ?>" style="width: 3rem; height: 3rem;">
                            </a>
                        </td>
                        <td><?=$item['cate_name'] ?></td>
                        <td><?=$item['cate_code'] ?></td>
                        <td><?=$item['goods_code'] ?></td>
                        <td><?=$item['goods_name'] ?></td>
                    </tr>
                 <?php
                        }
                    ?>
                </tbody>
            </table>
            </div>
        <div class="pull-left">
            <?= \app\widgets\LinkPagerExt::widget(['pagination' => $pagination]) ?>
        </div>
        </div>
    </div>